package com.alianzamedica.controllers.lot;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.objectsearch.web.tools.Converter;

import com.alianzamedica.models.TagModel;

/**
 * @author Carlos
 * 
 */
public class LotListAssignAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Integer medicId = Converter.string2Integer(request
				.getParameter("medicId"));
		String tagId = request.getParameter("tagId");
		Integer tagIdInt =Integer.parseInt(tagId);
		TagModel model = new TagModel();
		model.assignTag(medicId, tagIdInt);
		String mensaje = "El lote ha sido asignado correctamente";
		String linkRetorno = "/admin/lot/list.do";
		request.setAttribute("mensaje", mensaje);
		request.setAttribute("linkRetorno", linkRetorno);

		return mapping.findForward("success");
	}

}
